package com.xyzwps.mvckotlin.handler

import com.xyzwps.mvckotlin.handler.helper.ModelAndView
import com.xyzwps.mvckotlin.handler.helper.render
import com.xyzwps.mvckotlin.service.ArticleService
import org.springframework.stereotype.Component

@Component
class CommonHandler(val articleService: ArticleService) {

    fun index() = render {
        ModelAndView("redirect:/home")
    }

    fun home() = render {
        val articles = articleService.getSummaryBeforeId(null, 100)
        ModelAndView("home", mapOf("summaries" to articles))
    }
}